package com.lzy.cloud.order.service.impl;

import com.lzy.cloud.order.dtos.OrderAddressDto;
import com.lzy.cloud.order.entity.OrderAddress;
import com.lzy.cloud.order.mapper.OrderAddressMapperExt;
import com.lzy.cloud.order.service.OrderAddressService;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @description:订单收货地址
 * @author: liyun
 * @create: 2018-07-05 11:32
 */
@Service
public class OrderAddressServiceImpl implements OrderAddressService {

    @Autowired
    private OrderAddressMapperExt orderAddressMapperExt;

    @Override
    public OrderAddressDto queryListByOrderId(String orderId) {
        return orderAddressMapperExt.queryListByOrderId(orderId);
    }

    @Override
    public Long create(OrderAddressDto orderAddressDto) {
        OrderAddress orderAddress = DozerUtils.map(orderAddressDto, OrderAddress.class);
        return orderAddressMapperExt.insertSelective(orderAddress)>0 ? orderAddress.getId() : 0;
    }

    @Override
    public boolean update(OrderAddressDto orderAddressDto) {
        return orderAddressMapperExt.updateByPrimaryKeySelective(DozerUtils.map(orderAddressDto, OrderAddress.class)) > 0;
    }
}
